// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import 'vant/lib/index.css';
import 'element-ui/lib/theme-chalk/index.css';
import router from './router'
import App from './App'
import VueResouse from 'vue-resource'
import Axios from "axios"
import qs from "qs"
import store from "./store"
import './assets/css/css.less'
import $ from "jquery"
import lrz from "lrz"
import CryptoJS from 'crypto-js'
import VueClipboard from 'vue-clipboard2'
import {
	base64encode,
	base64decode,
	querystringify
} from './utils/base64'
import Base64 from 'js-base64'
import VConsole from 'vconsole'
Vue.use(Base64)
Vue.use(VueClipboard)
// 引入图片查看器
import preview from 'vue-photo-preview'
import 'vue-photo-preview/dist/skin.css'
Vue.use(preview)
import { SwipeCell, Button, Cell, Card, CellGroup, Toast, PullRefresh } from 'vant';
Vue.use(SwipeCell).use(Button).use(Cell).use(Card).use(CellGroup).use(Toast).use(PullRefresh);
import { NoticeBar, Badge, Popup, Picker } from 'vant';
Vue.use(NoticeBar).use(Badge).use(Popup).use(Picker);
import { Tab, Tabs } from 'vant';
Vue.use(Tab);
Vue.use(Tabs);
// 引入mint-ui
import {
	Loadmore
} from 'mint-ui';
import 'mint-ui/lib/style.css'
Vue.component(Loadmore.name, Loadmore);
// 引入VConsole
// Vue.prototype.$vConsole = new VConsole()
// 百度地图
Vue.prototype.BaiDuMap = "http://api.map.baidu.com/geocoder/v2/";

Vue.use(VueResouse)

// element 日期时间选择器
Vue.use(ElementUI);

import {
	Image,
	DatePicker,
	Upload,
	Loading,
	Notification,Tree,
	MessageBox
} from 'element-ui';
Vue.use(Tree)
Vue.use(DatePicker);
Vue.use(Upload);
Vue.use(Loading);
Vue.use(Image);

Vue.prototype.$notify = Notification;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$prompt = MessageBox.prompt;

Vue.config.productionTip = false;

Vue.prototype.HOST = store.state.RequestLink;
Vue.prototype.HOSTimg = store.state.RequestLinkimg;
// Vue.prototype.HOST1 = 'http://localhost:8501/dev';
// Vue.prototype.HOST1 = '/microservice/'
Vue.prototype.HOST1 = 'http://hyjt.hyycdj.cn/jeecgboot' // 生产
Axios.defaults.timeout = 180000

if (router.name != 'Login') {
	//跳转到登录页面
	router.push({
		name: 'Index',
		query: {}
	})
}

router.afterEach((to,from,next) => {
  window.scrollTo(0,0);
  // 或
  // window.scroll(0, 0);
});

// Vue页面已加载
Vue.prototype.TelliOSORAndroidVueMounted = function (msg) {
	// 安卓
	try {
		CallAndroidOrIOS.callAndroid('获取当前位置页面已加载', '');
	} catch (error) {}
	// 苹果
	// try {
	// 	window.webkit.messageHandlers.messageSend.postMessage({a:'获取当前位置页面已加载',b:""})
	// }
	// catch(error) { }
}

//跳转到android扫码页面
Vue.prototype.androidScan = function (inputName) {
	window.QRScanAjax = this.QRScanAjax;
	window.TellVue_QRScanResult_Ajax = this.QRScanAjax;
	this.$store.state.ScanQRCodeInputName = inputName;
	CallAndroidOrIOS.callAndroid("调用app原生扫描二维码/条码", inputName);
}

//加密 要delete
Vue.prototype.encryption = function (params) {
	var keyStr = 'l5TJHfZrmY38Hf2e2H1h0Q==';
	var key = CryptoJS.enc.Utf8.parse(keyStr);
	var srcs = CryptoJS.enc.Utf8.parse(params);
	var encrypted = CryptoJS.AES.encrypt(srcs, key, {
		mode: CryptoJS.mode.ECB,
		padding: CryptoJS.pad.Pkcs7
	});
	return encrypted.toString();
}

//解密 要delete
Vue.prototype.decryption = function (params) {

	var keyStr = 'l5TJHfZrmY38Hf2e2H1h0Q==';

	var key = CryptoJS.enc.Utf8.parse(keyStr);
	var decrypt = CryptoJS.AES.decrypt(params, key, {
		mode: CryptoJS.mode.ECB,
		padding: CryptoJS.pad.Pkcs7
	});

	return CryptoJS.enc.Utf8.stringify(decrypt).toString();
}

//http请求 要delete
Vue.prototype.httpRequest = function (url, params, success, isLoading_) {
	var that = this;
	if (isLoading_ && isLoading_ == 'isLoading_') {
		that.$emit('isLoading_', true, '拼命加载中');
	} else {
		that.$emit('isLoading', true, '拼命加载中');
	}
	params = JSON.stringify(params);
	console.log(params)
	params = that.encryption(params);
	// JSON.stringify(params)
	Axios.post(that.HOST + url, {
			'params': params
		})
		.then(function (res) {
			console.log(res)
			if (isLoading_ && isLoading_ == 'isLoading_') {
				that.$emit('isLoading_', false);
			} else {
				that.$emit('isLoading', false);
			}
			if (res.data.status == 1 || res.data.type == 1) {
				if (res.data.data) {
					try {
						res.data.data = JSON.parse(that.decryption(res.data.data));
					} catch (error) {
						res.data.data = that.decryption(res.data.data);
					}
				}
				console.log(res.data)
				success(res.data);
			} else if (res.data.status == 301) {
				that.ReturnToLogin();
			} else if (res.data.status == 501) {
				var Msg;
				if (res.data.Msg) {
					Msg = res.data.Msg;
				} else {
					Msg = '请求失败';
				}
				that.$alert(Msg, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						// 安卓
						try {
							CallAndroidOrIOS.updateAPP();
						} catch (error) {}
						// 苹果
						try {
							window.webkit.messageHandlers.messageSend.postMessage({
								a: '检查版本更新'
							})
						} catch (err) {}
					}
				})
			} else {
				var Msg;
				if (res.data.Msg) {
					Msg = res.data.Msg;
				} else {
					Msg = '请求失败';
				}
				that.$alert(Msg, '提示', {
					confirmButtonText: '确定'
				})
			}
		})
		.catch(function (res) {
			if (isLoading_ && isLoading_ == 'isLoading_') {
				that.$emit('isLoading_', false);
			} else {
				that.$emit('isLoading', false);
			}
			that.$alert('请求失败', '提示', {
				confirmButtonText: '确定'
			})
		})
}
//http请求
Vue.prototype.httpRequest1 = function (type = 'get', url, params, isLoading_) {
	var that = this;
	return new Promise((resolve, reject) => {
		if (!navigator.onLine) {
			reject('没有网络')
			that.$alert('没有网络', '提示', {
				confirmButtonText: '确定'
			})
			return
		}
		if (isLoading_ && isLoading_ == 'isLoading_') {
			// that.$emit('isLoading_', true, '拼命加载中');
		} else {
			// that.$emit('isLoading', true, '拼命加载中');
		}
		let configuration = {
			method: type,
			url: that.HOST1 + url
		}
		if (localStorage.getItem('jwt')) {
			configuration.headers = {
				Authorization: `Bearer${localStorage.getItem('jwt')}`,
				'cy-token': localStorage.getItem('jwt')
			}
		}
		if (type === 'get') {
			configuration.params = params
		} else if (type === 'post') {
			configuration.data = params
		}
		Axios(configuration).then((res) => {
			if (isLoading_ && isLoading_ == 'isLoading_') {
				that.$emit('isLoading_', false);
			} else {
				that.$emit('isLoading', false);
			}
			let result = res.data
			console.log('请求url: ', that.HOST1 + url, '请求参数： ', params, '返回参数：', result)
			let code = result.code
			console.log(result.detail)
			if (code == 0 || code == 200) {
				that.messageTipShow = true
				resolve(result);
			} else if (code == 999) {
				CallAndroidOrIOS.TipAudio();
				that.$alert(result.message, '提示', {
					confirmButtonText: '确定',
					callback: action => {}
				})
				that.messageTipShow = true
				resolve(result);
			} else if (code == 401) { // 超时
				CallAndroidOrIOS.TipAudio();
				that.$router.push({
					name: 'Index'
				})
			}else if (code == 5) { // 超时
				CallAndroidOrIOS.TipAudio();
				that.ReturnToLogin();
			} else if (code == 500 || code == 2) {
				// CallAndroidOrIOS.TipAudio();
				// that.$alert(result.message, '提示', {
				// 	confirmButtonText: '确定',
				// 	callback: action => {}
				// })
				resolve(result);
			} else if (code == 6) {
				CallAndroidOrIOS.TipAudio();
				let entity = result.entity;
				this.$store.state.globalConfirmMessage = {
					msg: entity.msg,
					orderSFNo: entity.orderSFNo,
					noType: entity.noType,
					opLink: entity.opLink,
					transportType: entity.transportType
				}
				$('.message-pop').css('display','block');
				// 安卓
				try {
					CallAndroidOrIOS.CancelScan();
				}
				catch (error) {}
				// 苹果
				try {
					window.webkit.messageHandlers.messageSend.postMessage({ a: '离开app原生半屏扫描二维码/条码' })
				}
				catch (error) {}
				reject(result)
			} else if (code == 7) { // app强制更新
				CallAndroidOrIOS.TipAudio();
				let detail = result.detail
				if (!detail) {
					detail = '有新版本，请更新';
				}
				that.$alert(detail, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						// 安卓
						try {
							CallAndroidOrIOS.updateAPP();
						} catch (error) {}
						// 苹果
						try {
							window.webkit.messageHandlers.messageSend.postMessage({
								a: '检查版本更新'
							})
						} catch (err) {}
					}
				})
			} else {
				// CallAndroidOrIOS.TipAudio();
				// let detail = result.detail
				// if (!detail) {
				// 	detail = '请求错误';
				// }
				// that.$alert(detail, '提示', {
				// 	confirmButtonText: '确定',
				// 	callback: action => {}
				// })
				reject(result)
			}
		}).catch((err) => {
			// CallAndroidOrIOS.TipAudio();
			console.log(err, '------', configuration.url)
			if (isLoading_ && isLoading_ == 'isLoading_') {
				that.$emit('isLoading_', false);
			} else {
				that.$emit('isLoading', false);
			}
			// that.$alert('请求接口：' + configuration.url + ',请求异常原因:' + err, '提示', {
			// 	confirmButtonText: '确定'
			// })
			reject(err)
		})
	})
}
// 获取当前位置信息 定位
Vue.prototype.onPlusReady = function (isLoading_is) {
	let that = this;
	if (isLoading_is != 'e') {
		this.$emit(isLoading_is, true, '正在获取当前位置');
	}
	if (this.$store.state.Device == 'android') {
		try {
			CallAndroidOrIOS.callAndroid('检查位置权限', '');
			window.checkGpsState = function (state){
				if (state) {
					CallAndroidOrIOS.callAndroid('位置权限', '');
				} else {
					that.Geolocation(isLoading_is);
				}
			};
		} catch (error) {}
		this.TelliOSORAndroidVueMounted('获取当前位置页面已加载');
		window.SetCurrAddress = this.SetCurrAddress;
	} else {
		this.Geolocation(isLoading_is);
	}
}
Vue.prototype.bgps_gps = function (bd_lng, bd_lat) {
    var X_PI = Math.PI * 3000.0 / 180.0;
    var x = bd_lng - 0.0065;
    var y = bd_lat - 0.006;
    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
    var gg_lng = z * Math.cos(theta);
    var gg_lat = z * Math.sin(theta);
    return {lng: gg_lng, lat: gg_lat}
}

// 获取当前位置
Vue.prototype.Geolocation = function (isLoading_is) {
	let that = this;
	console.log('获取定位信息')
	let geolocation = new BMapGL.Geolocation();
	geolocation.enableSDKLocation();
	geolocation.getCurrentPosition((r) => {
		console.log(r, '=========定位信息')
		if (r && r.point) {
			that.longitude = parseFloat(r.point.lng);
			that.latitude = parseFloat(r.point.lat);
			// that.longitude = '113.889338';
			// that.latitude = '22.499913';
			let params = {
				longitude: that.longitude, // 经度
				latitude: that.latitude, // 纬度
				cc: '2' // cc=1表示高德，cc=2表示百度，cc=3表示84坐标系
			}
            that.httpRequest1('post','/system/app/locationChangeAddress',params).then(res => {
					if (isLoading_is != 'e') {
						that.$emit(isLoading_is, false);
					}
					if (res.code == 200) {
						let addressInfo = res.data.addressComponent
						that.$store.state.CurrentCity = addressInfo.city;
						that.$store.state.CurrentDistrict = addressInfo.district
						that.$store.state.cityCode = addressInfo.citycode
						that.$store.state.longitude = that.longitude;
						that.$store.state.latitude = that.latitude;
						that.$store.state.CurrentLocation = res.data.formatted_address
						console.log(res.data, that.$store.state.CurrentLocation, '==解析之后打印===')
					}
				})
				.catch(function (res) {
					if (isLoading_is != 'e') {
						that.$emit(isLoading_is, false);
					}
					that.$alert('位置信息解析失败', '提示', {
						confirmButtonText: '确定'
					})
				})
		}
	}, {
		enableHighAccuracy: true
	})
}

Vue.prototype.ReceivingLatitud = function (lngad) {
}

// 请求加密
Vue.prototype.PublicEncryption = function (params) {
	if (this.$store.state.userInfo.userToken) {
		params.userToken = this.$store.state.userInfo.userToken;
	}
	if (!params.cellphone) {
		params.cellphone = this.$store.state.userInfo.cellphone;
	}
	params = JSON.stringify(params);
	console.log(params)
	return params = this.encryption(params);
}

// 登录失败 返回登录页
Vue.prototype.ReturnToLogin = function () {
	var that = this;
	that.$alert('登录失效或接口验证不通过、请重新登录！', '提示', {
		confirmButtonText: '确定',
		callback: action => {
			localStorage.removeItem('SXJF_USERDATA_second');
			localStorage.removeItem('SXJF_pwd_second');
			// 安卓 传手机号 记录轨迹
			try {
				CallAndroidOrIOS.callAndroidTrack('', '');
			} catch (error) {}
			// 苹果
			try {
				window.webkit.messageHandlers.messageSend.postMessage({
					a: '记住帐号密码',
					b: '',
					c: ''
				})
			} catch (error) {}
			that.$store.state.AviationWaybill.Waybill_SearchData = '';
			that.$store.state.AviationWaybill.Waybill_SearchType = 0;
			that.$store.state.Aviation_HistoryWaybill.Waybill_SearchData = '';
			that.$store.state.Aviation_HistoryWaybill.Waybill_SearchType = 0;
			that.$store.state.Waybill.Waybill_SearchData = '';
			that.$store.state.Waybill.Waybill_SearchType = 0;
			// 跳转到登录页面
			router.push({
				name: 'Index',
				query: {}
			})
		}
	})
}

// 关闭扫描框
Vue.prototype.closeScan = function (){
  // 安卓
  try {
    CallAndroidOrIOS.CancelScan();
  }
  catch(error) {}
  // 苹果
  try {
    window.webkit.messageHandlers.messageSend.postMessage({a:'离开app原生半屏扫描二维码/条码'})
  }
  catch(error)  {}
}
//打开或关闭 闪光灯
Vue.prototype.flashOpenOrClose = function() {
  var that = this;
  // 安卓
  try {
    if (that.ifflash) {
      CallAndroidOrIOS.setTorchEnabled_false(); // setTorchEnabled_false  闪光灯 关闭
      that.ifflash = false;
      // $('.AviationAllTransitScan header i.ICONFLASH').removeClass('icon-zidongshanguangdeng').addClass('icon-jinyongshanguangdeng');
    } else {
      CallAndroidOrIOS.setTorchEnabled_true();// setTorchEnabled_true  闪光灯 打开
      that.ifflash = true;
      // $('.AviationAllTransitScan header i.ICONFLASH').removeClass('icon-jinyongshanguangdeng').addClass('icon-zidongshanguangdeng');
    }
  }
  catch(error) {}
  // 苹果
  try {
    window.webkit.messageHandlers.messageSend.postMessage({a:'打开或关闭闪光灯'})
  }
  catch(error) {}
}

//上传文件之前的钩子，参数为上传的文件，若返回 false 或者返回 Promise 且被 reject，则停止上传。
Vue.prototype.beforeUpload = function (file) {
	var that = this;
	console.log(file)
	 if(file.size == 0){
	    that.$alert('上传失败，图片大小为0，请检查照片或重新拍照!', '提示', {
	       confirmButtonText: '确定',
	       callback: action => {
	        $('.el-loading-mask.is-fullscreen').css('display','none');
	       }
	    })
	    return false;
	  }
	try {
		var base64 = lrz(file).then(function (rst) {
			//成功时执行
			return rst.file;
		}).catch(function (error) {
			//失败时执行
			return file;
		})
		return base64;
	} catch (error) {
		console.log(error)
		const isLt2M = file.size / 1024 / 1024 < 10;
		if (!isLt2M) {
			that.$alert('上传图片大小不能超过 10MB!', '提示', {
				confirmButtonText: '确定',
				callback: action => {
					 $('.el-loading-mask.is-fullscreen').css('display','none');
				}
			})
		}
		return isLt2M;
	}
}
// 文件上传成功时的钩子
Vue.prototype.uploadSuccess = function (response, file, fileList) {
	console.log(response)
}
// 文件上传失败时的钩子
Vue.prototype.uploadError = function (err, file, fileList) {
	alert(err)
}

// 打电话
Vue.prototype.callPhone = function (phoneNum, businessCode, cityName) {
	event.stopPropagation();

	window.location.href = 'tel://'+ phoneNum ;
}
//排序
Vue.prototype.BubbleSort = function (arrayList) {
	let arrresult = [];
	for (let j = 0; j < arrayList.length - 1; j++) {
		for (let h = j + 1; h < arrayList.length; h++) {
			if (arrayList[j] > arrayList[h]) {
				arrresult = arrayList[j];
				arrayList[j] = arrayList[h];
				arrayList[h] = arrresult;
			}
		}
	}
	return arrayList;
}

//input聚焦
Vue.prototype.getFocus = function (input) {
	this.$refs[input].focus();
}

//清除输入框内容
Vue.prototype.clearInput = function (e) {
	this[e] = '';
}

// 返回 我的任务 页面
Vue.prototype.toWaybill = function () {
	// 需要重新请求数据
	store.state.Waybill_needRefresh = true;
	router.push({
		name: 'Waybill',
		query: {}
	})
}

// 返回 登录 页面
Vue.prototype.toLogin = function () {
	router.push({
		name: 'Login',
		query: {}
	})
}

// 点击 选择弹框 出现
Vue.prototype.typeSelect = function (e) {
	this.typeMShow = true;
}

// 选择弹框 消失
Vue.prototype.selectCancel = function (e) {
	this.typeMShow = false;
}

// ———————————————————————————————————配载单操作按钮事件———————————————————————————————————————————————————————————

// 点击导航按钮
Vue.prototype.Navigation = function (idx) {
	event.stopPropagation();
	let that = this;
	this.Navigate_addressList = [];
	// 装货地址列表
	let loading_addressList = that.shipmentListData[idx].issueAddrLiat;
	// 送货地址
	let Delivery_addressList = [];
	that.$emit('isLoading_', true, '拼命加载中');
	let postData = {
		shipmentId: that.shipmentListData[idx].shipmentID // 配载单id
	};
    this.httpRequest1('post','/kc-transport/tmsAppNew/queryDeliverReceiveAddrInfo',postData).then(res => {
		that.$emit('isLoading_', false);
		if (res.entity.length) {
			// Delivery_addressList = res.data;
			for (let m = 0; m < res.entity.length; m++) {
				Delivery_addressList[m] = {
					issueAddr1: res.entity[m].receivePartyAddr1, // 地址
					issuePhone: res.entity[m].receivePartyPhone, // 电话
					issueUser: res.entity[m].receivePartyContactName, // 联系人
					ORFlag: '收'
				}
			}
			that.Navigate_addressList = loading_addressList.concat(Delivery_addressList);
			if (that.Navigate_addressList.length) {
				that.typeMShow = true;
			} else {
				that.$alert('没有要导航的地址信息', '提示', {
					confirmButtonText: '确定'
				})
			}
		} else {
			that.Navigate_addressList = loading_addressList;
			if (that.Navigate_addressList.length) {
				that.typeMShow = true;
			} else {
				that.$alert('没有要导航的地址信息', '提示', {
					confirmButtonText: '确定'
				})
			}
		}
	})
}
// 选择具体要 导航的地址
Vue.prototype.Navigate_SelectComit = function (Navigate_detailAddress) {
	this.typeMShow = false;
	// 安卓
	try {
		CallAndroidOrIOS.callAndroid('导航', Navigate_detailAddress);
	} catch (error) {}
	// 苹果
	try {
		window.webkit.messageHandlers.messageSend.postMessage({
			a: '导航',
			b: Navigate_detailAddress
		})
	} catch (error) {}
}
// ——————————————————————————————————————————————————————————————————————————————————————————————

// -------------------------------------------------我的任务/历史任务页面多装货地址弹出框点击事件 结束------------------------------------------
// 获取当前时间并处理时间格式
Vue.prototype.timestampFormat = (timestamp, format) => {
	let result = ''
	let zeroFill = val => val < 10 ? '0' + val : val
	format = format || 'YYYY-MM-DD'
	if (!timestamp) {
		result = '-'
	} else {
		let sFormat = format
		format = format.split(' ')
		let dateFormat = format[0]
		let timeFormat = format[format.length - 1]
		let dateSymbol = dateFormat.match(/[^Y,^M,^D]/)[0]
		let timeSymbol = timeFormat.match(/[^h,^m,^s]/)[0]
		let clearance = sFormat.replace(dateFormat, '').replace(timeFormat, '')
		let datetime = new Date(timestamp)
		let year = datetime.getFullYear()
		let month = zeroFill(datetime.getMonth() + 1)
		let day = zeroFill(datetime.getDate())
		let hours = zeroFill(datetime.getHours())
		let minute = zeroFill(datetime.getMinutes())
		let second = zeroFill(datetime.getSeconds())
		if (dateFormat.match(/Y/)) {
			result += year
		}
		if (dateFormat.match(/M/)) {
			result += dateSymbol + month
		}
		if (dateFormat.match(/D/)) {
			result += dateSymbol + day
		}
		if (timeFormat.match(/h/)) {
			result += clearance + hours
		}
		if (timeFormat.match(/m/)) {
			result += timeSymbol + minute
		}
		if (timeFormat.match(/s/)) {
			result += timeSymbol + second
		}
	}

	return result.replace(/^[^\d]+/, '')
}

// 关闭地址弹框
Vue.prototype.closeAddress = function () {
	event.stopPropagation();
	$('.MultiAddress').css('display', 'none');
}


Vue.prototype.goPrev = function (){
  router.go(-1);
}

// 设置缓存
Vue.prototype.setItem = function(params) {
  let obj = {
    name: '',
    value: '',
    expires: '',
    startTime:new Date().getTime() // 记录何时将值存入缓存，毫秒级
  }
  let options = {};
  // 将obj和传进来的params合并
  Object.assign(options,obj,params);
  if (options.expires) {
  // 如果options.expires设置了的话
  // 以options.name为key，options为值放进去
    localStorage.setItem(options.name,JSON.stringify(options));
  } else {
  // 如果options.expires没有设置，就判断一下value的类型
    let type = Object.prototype.toString.call(options.value);
    // 如果value是对象或者数组对象的类型，就先用JSON.stringify转一下，再存进去
    if (Object.prototype.toString.call(options.value) == '[object Object]') {
      options.value = JSON.stringify(options.value);
    }
    if (Object.prototype.toString.call(options.value) == '[object Array]') {
      options.value = JSON.stringify(options.value);
    }
    localStorage.setItem(options.name,options.value);
  }
}

// 拿到缓存
Vue.prototype.getItem = function(name){
  let item = localStorage.getItem(name);
  // 先将拿到的试着进行json转为对象的形式
  try {
      item = JSON.parse(item);
  } catch(error) {
  	// 如果不行就不是json的字符串，就直接返回
    item = item;
  }
  // 如果有startTime的值，说明设置了失效时间
  if (item && item.startTime) {
      let date = new Date().getTime();
      // 何时将值取出减去刚存入的时间，与item.expires比较，如果大于就是过期了，如果小于或等于就还没过期
      if (date - item.startTime > item.expires) {
        // 缓存过期，清除缓存，返回false
		localStorage.removeItem(name);
		return false;
      } else {
        // 缓存未过期，返回值
        return item.value;
      }
  } else {
    // 如果没有设置失效时间，直接返回值
    return item;
  }
}

Vue.prototype.onError = function (copytext) {
	console.log(copytext)
}
Vue.prototype.stopevent = function () {
	event.stopPropagation();
}
Date.prototype.Format = function (fmt) { // author: meizz
	var o = {
		"M+": this.getMonth() + 1, // 月份
		"d+": this.getDate(), // 日
		"h+": this.getHours(), // 小时
		"m+": this.getMinutes(), // 分
		"s+": this.getSeconds(), // 秒
		"q+": Math.floor((this.getMonth() + 3) / 3), // 季度
		"S": this.getMilliseconds() // 毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
}
/* eslint-disable no-new */
new Vue({
	el: '#app',
	router,
	Axios,
	store,
	$,
	components: {
		App
	},
	template: '<App/>'
})
